<?php
/**
 * @category   Application_Extensions
 * @package    Talktangle Plugin 
 * @copyright  Idragon Co., Ltd.
 * @license
 */
class Talktangle_Widget_ContentController extends Engine_Content_Widget_Abstract {
	
	/**
	 * Redirect to other widget
	 */
	public function indexAction() {
	   if (!Engine_Api::_()->core()->hasSubject('user')) {
			return $this->setNoRender();
		}
		// Get subject
		$this->view->subject = $viewer = $subject = Engine_Api::_()->core()
			->getSubject('user');
		
		$request = Zend_Controller_Front::getInstance()->getRequest();
		$action = $request->getParam('type');
        $module = 'talktangle';
        
        
        if (empty($action)) {
            $action = 'feed';
            $module = 'activity';
        } 
        else {
            $action .= 'tangle';
        }
		if (empty($action)) {
			return $this->setNoRender();
		}
       
	
		// Get content of other widget based on param "act"
		$content = '';
		try {
			$structure = array (
				'type' => 'widget', 
				'name' => $module .'.' .$action, 
				'request' => $request, 
				'action' => 'index'
			);
			
			// Create element (with structure)
			$element = new Engine_Content_Element_Container(array (
				'elements' => array (
					$structure
				), 
				'decorators' => array (
					'Children'
				)
			));
			
			$content = $element->render();
		}
		catch (Exception $ex) {
			
		}
		
		// Set to current content
		$this->setContent($content);
		// return $this->setNoRender();
	}
}